import http from "@/http";

export const getProductListAPI = (
  params: IProductParams
): RES<ITableResult<IProductModel>> => http.get("/product/list", { params });
// /brand/listAll 获取全部品牌列表
export const ApiBrandListAll = (): RES<IBrandList[]> =>
  http.get("/brand/listAll");
// /brand/list   根据品牌名称分页获取品牌列表
export const ApiBrandList = (params: any): RES<ITableResult<IBrandList>> =>
  http.get("/brand/list", { params });
// /brand/update/factoryStatus 批量更新厂家制造商状态
export const ApiFactoryStatus = (
  ids: number[],
  factoryStatus: number
): RES<number> =>
  http.post(
    `/brand/update/factoryStatus?factoryStatus=${factoryStatus}&ids=${ids}`
  );
// /brand/update/showStatus 批量更新显示状态
export const ApiShowStatus = (ids: number[], showStatus: number): RES<number> =>
  http.post(`/brand/update/showStatus?ids=${ids}&showStatus=${showStatus}`);

//   根据商品名称或货号模糊查询
export const getProductListByNameAPI = (
  params: any
): RES<ITableResult<IProductModel>> =>
  http.get(" /product/simpleList", { params });

//商品分类
export const productCategoryListApi = (
  params: IProductCategoryParamsModel
): RES<ITableResult<IProductCategoryList>> =>
  http.get(
    `/productCategory/list/${params.parentId}?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
  );

//删除商品
export const deleteProductCategoryApi = (id: number): RES<any> =>
  http.post(`/productCategory/delete/${id}`);

// 查询所有一级分类及子分类
export const withChildrenApi = (): RES<IFirstCagetegy[]> =>
  http.get(`/productCategory/list/withChildren`);

// 获取所以商品属性分类及其下属性
export const getProductCategoryApi = (): RES<IProductCategory[]> =>
  http.get("/productCategory/list/withChildren");

// 获取全部品牌列表
export const getBrandListAllApi = (): RES<IBrandListAll[]> =>
  http.get("brand/listAll");

// 获取商品属性分类数据
export const getProductAttributesListApi = (
  params: IProductParams
): RES<IProductLListModel> =>
  http.get("/productAttribute/category/list", { params });

// 获取属性类型
export const getProductAttributeApi = (): RES<IProductAttribute[]> =>
  http.get("/productAttribute/category/list/withAttr");
// 获取全部商品专题
export const getSubjectAllApi = (): RES<ISubjectAll[]> =>
  http.get("/subject/listAll");

// /productAttribute/create 添加商品属性信息
export const ApiProductAttribute = (pmsBrand: IBrandParams): RES<number> =>
  http.post("/brand/create", pmsBrand);
// /brand/delete/{id} 删除品牌
export const ApiDeleteId = (id: number): RES<number> =>
  http.get(`/brand/delete/${id}`);
// /brand/{id} 根据编号查询品牌信息
export const ApiBrandId = (id: number): RES<IBrandId> =>
  http.get(`/brand/${id}`);
// /brand/update/{id} 更新品牌
export const ApiBrandUpdate = (
  id: number,
  pmsBrandParam: IBrandId
): RES<IBrandId> => http.post(`/brand/update/${id}`, pmsBrandParam);
//批量设为新品56
export const updateNewStatusAPI = (
  ids: string | number,
  newStatus: number
): RES<number> =>
  http.post(`/product/update/newStatus?ids=${ids}&newStatus=${newStatus}`);

// 批量上下架12
export const updatePudeleteStatusblishStatusAPI = (
  ids: string | number,
  publishStatus: number
): RES<number> =>
  http.post(
    `/product/update/publishStatus?ids=${ids}&publishStatus=${publishStatus}`
  );

// 批量推荐商品34
export const updateRecommendStatusAPI = (
  ids: string | number,
  recommendStatus: number
): RES<number> =>
  http.post(
    `/product/update/recommendStatus?ids=${ids}&recommendStatus=${recommendStatus}`
  );

// 批量修改删除状态8
export const deleteStatusAPI = (
  deleteStatus: number,
  ids: string | number
): RES<number> =>
  http.post(
    `/product/update/deleteStatus?deleteStatus=${deleteStatus}&ids=${ids}`
  );

//商品分类：修改导航栏显示状态
export const updateProductCategoryNavStatusApi = (
  params: IProductCategoryNavStatusModel
): RES<any> =>
  http.post(
    `/productCategory/update/navStatus?ids=${params.ids.join(",")}&navStatus=${
      params.navStatus
    }`
  );
//商品分类：修改显示状态
export const updateProductShowStatusCategoryApi = (
  params: showStatus
): RES<any> =>
  http.post(
    `/productCategory/update/showStatus?ids=${params.ids.join(
      ","
    )}&showStatus=${params.showStatus}`
  );
//商品分类：添加分类
export const updateProductCategoryApi = (
  productCategoryParam: IUpdateProductCategoryModel
): RES<any> =>
  http.post(
    `/productCategory/create
`,
    productCategoryParam
  );
//上传
export const uploadApi = () => http.post(`/minio/upload`);
//获取所有商品属性分类及其下属性
export const productAttributeApi = (): RES<IProductAttributeModel[]> =>
  http.get(`/productAttribute/category/list/withAttr`);
//根据id获取商品分类
export const getProductCategoryByIdApi = (
  id: number
): RES<IProductCategoryList> => http.get(`/productCategory/${id}`);
//修改商品分类
export const editProductCategoryApi = (
  id: number,
  params: IUpdateProductCategoryModel
): RES<any> => http.post(`/productCategory/update/${id}`, params);

// 修改商品属性分类
export const updateProductAPI = (
  id: number,
  name: string
): RES<IUpdateProductDate> =>
  http.post(`/productAttribute/category/update/${id}?name=${name}`);

// 删除商品属性
export const deleteProductAPI = (id: number): RES<IUpdateProductDate> =>
  http.get(`/productAttribute/category/delete/${id}`);

// 添加商品属性
export const createProductAPI = (name: string): RES<IUpdateProductDate> =>
  http.post(`/productAttribute/category/create?name=${name}`);

// 商品属性属性与参数列表跳转
export const attributeJumpAPI = (
  cid: number,
  pageNum: number,
  pageSize: number,
  type: number,
): RES<IAttributeJumpData> =>
  http.get(
    `/productAttribute/list/${cid}?pageNum=${pageNum}&pageSize=${pageSize}&type=${type}`
  )

// 商品属性属性列表添加功能
export const productAttributeCreateAPI = (params: productAttributeCreateParams): RES<IAttributeJumpData> => http.post(`/productAttribute/create`, params);

// 商品属性属性列表删除功能
export const deleteAttributeListAPI = (id: number[]): RES<IUpdateProductDate> => http.post(`/productAttribute/delete?ids=${id.join(',')}`,)

// 商品属性属性列表编辑功能
export const productAttributeUpdateAPI = (params: productAttributeCreateParams, id: number): RES<IAttributeJumpData> => http.post(`/productAttribute/update/${id}`, params);
